<?php 

    /**
     * This file is part of the Intelligencer package.
     * For the full copyright and license, please view the LICENSE
     * file that was distributed with this source code.
     * 
     * @author      drapeko <roman.drapeko@gmail.com>
     * @copyright   Roman Drapeko <roman.drapeko@gmail.com>, 2009 - present
     */

    /**
     * The abstract Intelligencer class that defines all the common parameters/operations for 
     * all possible Intelligencers. 
     * 
     * If you need to create your custom Intelligencer this class can be extended.
     * 
     * @author drapeko
     */
    abstract class itIntelligencer {
        
        protected $name = null;
        protected $manager = null;
        protected $control = false;
    
        /**
         * Constructor. Accepts the name of the Intelligencer.
         * @param string $name
         */
        public function __construct($name = null) {
            $this->name = $name;
        }
        
        /**
         * Set the name
         * @param string $name
         * @return Intelligencer itself
         */
        public function setName($name) {
            $this->name = $name;
            return $this;
        }
        
        /**
         * Returns intelligencer name
         * @return string
         */
        public function getName() {
            return $this->name;
        }
        
        /**
         * Sets the manager
         * @param itManager $m
         * @return Intelligencer itself
         */
        public function setManager(itManager $m) {
            $this->manager = $m;
            return $this;
        }
        
        /**
         * Returns the manager
         * @return itManager
         */
        public function getManager() {
            return $this->manager;
        }

        /**
         * Sets the intelligencer in Control/Uncontrol mode according to the $control incoming parameter
         * which is true by default. Intelligencer is used by Manager only if the first one in 'control' mode.
         * 
         * @param boolean $control true
         * @return itManager
         */
        public function control($control = true) {
            $this->control = $control;
            return $this->manager;
        }
        
        /**
         * Sets the intelligencer in uncontrol mode
         * @return itIntelligencer itself
         */
        public function uncontrol() {
            $this->control = false;
            return $this;
        }
        
        /**
         * Checks whether Intelligencer in control mode
         * @return boolean
         */
        public function inControl() {
            return $this->control;
        }
        
        /**
         * Destructor
         * @return void
         */
        public function destroy() {
            
        }
        
        /**
         * Ask Intelligencer to load the class according to all the instructions (cache, rules etc). 
         * This function is widely used by the itManager.
         * @param $className
         * @return boolean
         */
        abstract public function load($className);
    }

?>